<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组分隔</title>
</head>
<body>
    <script>
        let arr = ['aa', 'bb', 'cc', 'ee'];
        let fengefu ='|';
        //初始化结果字符串
        let result ='';
        //使用循环遍历数组
        for(let i =0 ;i <arr.length;i++){
            //将当前元素与分隔符连接起来
            result += arr[i];
            //如果不是最后一个元素，添加分隔符
            if(i!== arr.length-1){
                result += fengefu;
            }
        }
        //输出结果
        console.log(result);
    </script>
</body>
</html>